package com.lxw.multidb.modules.sql.entity;

import cn.tannn.jdevelops.result.bean.SerializableBean;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

/**
 * 数据链接表
 *
 * @author tnnn
 * @version V1.0
 * @date 2025-08-26
 */
@Entity
@Table(name = "db_connection")
@Comment("数据链接表")
@Schema(description = "数据链接")
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@DynamicUpdate
@DynamicInsert
public class DbConnection extends SerializableBean<DbConnection> {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Comment("id")
    private Integer id;

    /**
     * 数据库类型[mysql、kingbase、sqlserver、postgresql等]
     */
    @Schema(description = "数据库类型[mysql、kingbase、sqlserver、postgresql等]")
    @Column(columnDefinition = "varchar(50)", nullable = false)
    @Comment("数据库类型[mysql、kingbase、sqlserver、postgresql等]")
    private String dbType;

    /**
     * host
     */
    @Schema(description = "host")
    @Column(columnDefinition = "varchar(50)", nullable = false)
    @Comment("host")
    private String host;

    /**
     * 端口
     */
    @Schema(description = "端口")
    @Comment("端口")
    private Integer port;

    /**
     * 用户名
     */
    @Schema(description = "用户名")
    @Column(columnDefinition = "varchar(50)", nullable = false)
    @Comment("用户名")
    private String username;

    /**
     * 密码
     */
    @Schema(description = "密码")
    @Column(columnDefinition = "varchar(50)", nullable = false)
    @Comment("密码")
    private String password;

}
